import Vue from 'vue'
import Vuex from 'vuex'
import { setItem, getItem } from '../utils/storage'

Vue.use(Vuex)

const TOUKEN_KEY = 'TOUTIAO_USER'

export default new Vuex.Store({
  state: {
    // user: null
    // user:JSON.parse(window.localStorage.getItem(TOUKEN_KEY))
    user: getItem(TOUKEN_KEY)
  },
  mutations: {
    setUser(state, user) {
      state.user = user
      // window.localStorage.setItem(TOUKEN_KEY, JSON.stringify(state.user))
      setItem(TOUKEN_KEY, state.user)
    }
  },
  actions: {
  },
  modules: {
  }
})
